#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        if ((s[0] == s[1]) && (s[1] == s[2]) && (s[2] == s[3])) cout << "No" << endl;
        else if ((s[0] == s[1] && s[1] == s[2])
            || (s[0] == s[1] && s[1] == s[3])
            || (s[0] == s[2] && s[0] == s[3])
            || (s[1] == s[2] && s[2] == s[3]))
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}